﻿using datatablegenerator.Common;
using datatablegenerator.Entity;
using datatablegenerator.Enums;
using System;
using System.Collections.Generic;
using System.Data.Common;

namespace datatablegenerator.Factory.DBFactory
{
    public interface IDbContext
    {
        DbConnection conn { get; set; }

        /// <summary>
        /// 数据库连接
        /// </summary>
        /// <param name="connectionStr"></param>
        /// <returns></returns>
        Tuple<bool, string> ConnectionDb(string connectionStr);

        /// <summary>
        /// 关闭数据库连接
        /// </summary>
        /// <returns></returns>
        Tuple<bool, string> CloseConnection();


        #region 因为 业务场景简单 所有没有 将IDbContext 拆分成更细的接口

        Tuple<bool, string> AnalyzeConnectionString(DBType dBType);

        /// <summary>
        /// 判断数据表是否存在
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        Tuple<bool, string> IsTableExist(string table);

        /// <summary>
        /// 创建数据表SQL
        /// </summary>
        /// <param name="db"></param>
        /// <param name="dt"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        Tuple<bool, string> CreateDataTableSQL(string dt, List<DatatableDTO> dto);

        /// <summary>
        /// 创建数据表
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="dt"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        Tuple<bool, string> CreateDataTable(string sql, string dt, List<DatatableDTO> dto);

        #endregion

    }
}
